import React, { Component } from 'react'
import {Link,Route} from 'react-router-dom'
import Detail from './Detail/Detail'
export default class Demo2 extends Component {
    state={
        arr:[
            {id:'001',title:'消息1'},
            {id:'002',title:'消息2'},
            {id:'003',title:'消息3'},
        ]
    }
    render() {
        let {arr} = this.state
        return (
            <div>
                <ul>
                    {
                        arr.map((v)=>{
                            return(
                                <li key={v.id}>
                                    <Link to={`/home/demo2/detail/${v.id}/${v.title}`}>{v.title}</Link>
                                </li>
                            )
                        })
                    }    
                </ul>
                <hr />
                <Route path="/home/demo2/detail/:id/:title" component={Detail} />           
            </div>
        )
    }
}
